// app.js
const {areq} = require('./utils/util.js');
App({
  onLaunch() {
    // 展示本地存储能力


    //登录
    wx.login({
      success: (res) => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
          if(res.code){
            areq({
              url:`${this.globalData.localSrc}/auth/mp-login/` + res.code,
              method:'GET'
            })
            .then(res=>{
              if(res.ok){
                const userInfo = res.data.userinfo;
                this.globalData.userInfo = userInfo;
                console.log(userInfo);
              }
            })
          }
        }
    })
  },

  globalData: {
    userInfo: null,
    localSrc:'http://localhost:1234/'//本地地址
  }
})
